/**
 * 文件描述与文件指针之间的转换
*/

#include <stdio.h>
#include <string.h>
#include <unistd.h>

int main()
{
    const char *str = "I am FILE point output\n";
    const char *str1 = "I am FILE descriptor output\n";

    FILE *fp = fdopen(STDERR_FILENO, "w");
    if (fp != NULL)
    {
        fprintf(fp, "%s", str);
    }

    int fd = fileno(fp);
    if (fd != -1)
    {
        write(fd, str1, strlen(str1));
    }

    return 0;
}